package com.biz.service.basic;


import com.biz.model.Hmodel.basic.Tagent;
import com.biz.model.Pmodel.User;
import com.biz.model.Pmodel.basic.PagentTree;
import com.biz.model.Pmodel.sys.Dynamic;
import com.biz.service.base.BaseServiceImpl;
import com.framework.dao.hdao.BaseDaoI;
import com.framework.dao.mdao.DaoSupport;
import com.framework.model.Paging;
import com.framework.model.Params;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wxs on 2017/6.6/
 */
@Service("dynamicService")
public class DynamicServiceImpl extends BaseServiceImpl<Tagent> implements DynamicServiceI {

    @Resource(name = "daoSupport")
    private DaoSupport dao;
    @Autowired
    private BaseDaoI<Tagent> agentDao;

    @Override
    public Paging findDynamicGrid(Params sqlParams) {
        Paging paging= dao.findForPagings("dynamicMapper.findDynamicGrid",sqlParams,"dynamicMapper.findDynamicCount",sqlParams);
        return paging;
    }

    @Override
    public void saveDynamic(Dynamic Dynamic) throws Exception {
        dao.save("dynamicMapper.saveDynamic",Dynamic);
    }

    @Override
    public void updateDynamic(Dynamic Dynamic) throws Exception {
        dao.save("dynamicMapper.updateDynamic",Dynamic);
    }

    @Override
    public Dynamic findById(String id) throws Exception {
        Map<String,String> map=new HashMap<>();
        map.put("id",id);
        return (Dynamic) dao.findForObject("dynamicMapper.findById",map);
    }

    @Override
    public void delDynamicById(String ids) throws Exception {
        String [] idList=ids.split(",");
        for (String id:idList) {
          dao.delete("dynamicMapper.deleteDynamic",id);
        }
    }

}
